"""
    时间：2019/10/23
    作者：徐飞
    内容：20期第二次作业
"""

import numpy as np
import cv2 as cv

"""
Hough直线检测实现
"""
# file = r"building.jpg"
# img = cv.imread(file)
# grey = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# edges = cv.Canny(grey, 50, 150)
# lines = cv.HoughLinesP(edges, 1, np.pi/180, 30, minLineLength=50, maxLineGap=8)
# lines = lines[:, 0, :]
# for a, b, c, d in lines:
#     cv.line(img, (a, b), (c, d), (0, 255, 0), 3)
# cv.imshow('houghlines', img)
# cv.waitKey(0)
# cv.destroyAllWindows()

"""
Harris 角点检测算子
"""

img = cv.imread(r"chessboard.png", 0)
img = cv.resize(img, (500, 500))
dst = cv.cornerHarris(img, 2, 3, 0.05)
dst = cv.resize(dst, (500, 500))
display = np.hstack((img, dst))
cv.imshow("result", display)
if cv.waitKey(0) & 0xff == 27:
    cv.destroyAllWindows()
